using System;
using System.Collections.Generic;
using System.Text;

namespace Deepcode.Flux.Core.Services.Errors
{
	/// <summary>
	/// The ErrorService provides a mechanism to invoke errors within the application
	/// and have them fed back to the user using a standard format.
	/// </summary>
	public class ErrorService
	{
		/// <summary>
		/// Static method to allow quick access to this service
		/// </summary>
		/// <returns></returns>
		public static ErrorService Service() { return new ErrorService(); }
		
		/// <summary>
		/// Invokes and handles the error specified. (Handles by redirecting to 
		/// the public error notification script)
		/// </summary>
		/// <param name="Error"></param>
		public void DoError( StandardError Error )
		{
			System.Web.HttpContext ht = System.Web.HttpContext.Current;
			if( ht == null ) throw new Exception("Cannot obtain current HttpContext");
			ht.Response.Redirect(String.Format("~/admin/public/notify/error.aspx?reason={0}", Error.ToString()), true);
		}


	}
}
